﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using PagedList;
using PagedList.Mvc;

namespace shop.Areas.Main.Controllers
{
    public class TimKiemController : Controller
    {
        //
        // GET: /TimKiem/
        private LongHAEntities db = new LongHAEntities();
        public ActionResult Index()
        {
          
                return RedirectToAction("index", "Home");
          
         
        }
        public ActionResult timkiem(string Search,int ? page)
        {
            int pagesize = 20;
            int pagenumber = (page ?? 1);
            ViewBag.tukhoa = Search;
            var model = db.SanPhams
                .Where(p => p.TenSP.Contains(Search)).ToList();
            return View(model.ToPagedList(pagenumber,pagesize));
        }

        //
        // GET: /TimKiem/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /TimKiem/Create

        //public ActionResult Create()
        //{
        //    return View();
        //}

        ////
        //// POST: /TimKiem/Create

        //[HttpPost]
        //public ActionResult Create(FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add insert logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        ////
        //// GET: /TimKiem/Edit/5

        //public ActionResult Edit(int id)
        //{
        //    return View();
        //}

        ////
        //// POST: /TimKiem/Edit/5

        //[HttpPost]
        //public ActionResult Edit(int id, FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add update logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}

        ////
        //// GET: /TimKiem/Delete/5

        //public ActionResult Delete(int id)
        //{
        //    return View();
        //}

        ////
        //// POST: /TimKiem/Delete/5

        //[HttpPost]
        //public ActionResult Delete(int id, FormCollection collection)
        //{
        //    try
        //    {
        //        // TODO: Add delete logic here

        //        return RedirectToAction("Index");
        //    }
        //    catch
        //    {
        //        return View();
        //    }
        //}
    }
}
